/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.dp1.pucp.Logistica.Vista;

import java.awt.event.ActionListener;
import javax.swing.JFrame;
import javax.swing.table.DefaultTableModel;

/**
 *
 * @author ubuntu64
 */
public class ProcesarPedidoGUI extends javax.swing.JPanel {

    public JFrame padre;
        
    public JFrame getPadre(){
        return padre;
    }
    /**
     * Creates new form ProcesarPedidoGUI
     */
    public ProcesarPedidoGUI() {
        initComponents();
    }

    public void addCalcularListener(ActionListener ml){
        this.btnCalcular.addActionListener(ml);
    }
    
    public void addSiguienteListener(ActionListener ml){
        this.btnSiguiente.addActionListener(ml);
    }
    
  
    
       public void setCantidadProductos(int cant1, int cant2, int cant3){
//        this.txtProducto1.setText(""+cant1);
//        this.txtProducto2.setText(""+cant2);
//        this.txtProducto3.setText(""+cant3);
        
                ((DefaultTableModel) tblCantidades.getModel()).setRowCount(3);
                tblCantidades.setValueAt(cant1,0, 1);
                tblCantidades.setValueAt(cant2, 1, 1);
                tblCantidades.setValueAt(cant3, 2, 1);
               
                 ((DefaultTableModel) tblCantidades.getModel()).setRowCount(3);
                tblCantidades.setValueAt("unidades",0, 2);
                tblCantidades.setValueAt("unidades", 1, 2);
                tblCantidades.setValueAt("unidades", 2, 2);
    }
         
    public void setNombreProductos (String nombre1, String nombre2, String nombre3){
//        this.lblProducto1.setText(nombre1);
//        this.lblProducto2.setText(nombre2);
//        this.lblProducto3.setText(nombre3);
        
        ((DefaultTableModel) tblCantidades.getModel()).setRowCount(3);
                tblCantidades.setValueAt(nombre1,0, 0);
                tblCantidades.setValueAt(nombre2, 1, 0);
                tblCantidades.setValueAt(nombre3, 2, 0);
    }
    
    public void inhabilitarCalcular(){
        this.btnCalcular.setEnabled(false);
    }
    
    public void inhabilitarSiguiente(){
        this.btnSiguiente.setEnabled(false);
    }
            
           
    
    public int getCantidad1(){
        String cant1 = this.tblCantidades.getValueAt(0, 1).toString();
        int a= Integer.parseInt(cant1);
        return a;
    }
    
     public int getCantidad2(){
         String cant1 = this.tblCantidades.getValueAt(1, 1).toString();
       
        int a= Integer.parseInt(cant1);
        return a;
    }
     
      public int getCantidad3(){
         String cant1 = this.tblCantidades.getValueAt(2, 1).toString();
       
        int a= Integer.parseInt(cant1);
        return a;
    }
 
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabel1 = new javax.swing.JLabel();
        jSeparator1 = new javax.swing.JSeparator();
        jLabel2 = new javax.swing.JLabel();
        jSeparator2 = new javax.swing.JSeparator();
        jLabel3 = new javax.swing.JLabel();
        btnCalcular = new javax.swing.JButton();
        btnSiguiente = new javax.swing.JButton();
        jSeparator3 = new javax.swing.JSeparator();
        jScrollPane1 = new javax.swing.JScrollPane();
        tblCantidades = new javax.swing.JTable();

        jLabel1.setFont(new java.awt.Font("Ubuntu", 1, 15)); // NOI18N
        jLabel1.setText("Procesar Pedidos de Productos");

        jLabel2.setText("Se procesarán los pedidos que han sido incluidos en la última simulación");

        jLabel3.setFont(new java.awt.Font("Ubuntu", 2, 10)); // NOI18N
        jLabel3.setText("Haga click en Calcular para hallar la cantidad de galletas según simulación");

        btnCalcular.setFont(new java.awt.Font("Ubuntu", 0, 10)); // NOI18N
        btnCalcular.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/calculadora.png"))); // NOI18N
        btnCalcular.setText("Calcular");
        btnCalcular.setBorderPainted(false);
        btnCalcular.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btnCalcular.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);

        btnSiguiente.setFont(new java.awt.Font("Ubuntu", 0, 10)); // NOI18N
        btnSiguiente.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/next.png"))); // NOI18N
        btnSiguiente.setText("Siguiente");
        btnSiguiente.setBorderPainted(false);
        btnSiguiente.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btnSiguiente.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);

        tblCantidades.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null},
                {null, null, null},
                {null, null, null},
                {null, null, null}
            },
            new String [] {
                "PRODUCTO", "CANTIDAD", "UNIDADES"
            }
        ));
        tblCantidades.setAutoscrolls(false);
        jScrollPane1.setViewportView(tblCantidades);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(btnCalcular)
                .addGap(41, 41, 41)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 375, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
            .addGroup(layout.createSequentialGroup()
                .addGap(29, 29, 29)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jSeparator2)
                        .addContainerGap())
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(jSeparator1, javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addGap(0, 59, Short.MAX_VALUE)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                    .addComponent(jLabel1)
                                    .addComponent(jLabel3)
                                    .addComponent(jLabel2)
                                    .addGroup(layout.createSequentialGroup()
                                        .addComponent(btnSiguiente)
                                        .addGap(245, 245, 245))))
                            .addComponent(jSeparator3))
                        .addGap(20, 20, 20))))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(27, 27, 27)
                .addComponent(jLabel1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel2)
                .addGap(13, 13, 13)
                .addComponent(jLabel3)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jSeparator2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(34, 34, 34)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 92, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jSeparator3, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(btnSiguiente))
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(btnCalcular)
                        .addGap(0, 0, Short.MAX_VALUE))))
        );
    }// </editor-fold>//GEN-END:initComponents

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnCalcular;
    private javax.swing.JButton btnSiguiente;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JSeparator jSeparator1;
    private javax.swing.JSeparator jSeparator2;
    private javax.swing.JSeparator jSeparator3;
    private javax.swing.JTable tblCantidades;
    // End of variables declaration//GEN-END:variables
}
